package com.baizhi.controller;

import com.baizhi.dto.request.StudentDTO;
import com.baizhi.service.StudentService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@Tag(name="学生管理模块", description = "学生管理模块的控制器")
public class StudentController {
    @Autowired
    private StudentService studentService;


    @GetMapping("/student/logOut")
    public ResponseEntity<String> logOutStudent(@RequestParam("userId") Integer userId){
        Boolean flag = studentService.logOutStudent(userId);
        if(flag){
            return new ResponseEntity<>("成功",HttpStatusCode.valueOf(200));
        }else{
            return new ResponseEntity<>("失败",HttpStatusCode.valueOf(500));
        }
    }

    @PostMapping("/student/regist")
    public ResponseEntity<String> studentRegist(@RequestBody @Valid StudentDTO studentDTO){
        System.out.println(studentDTO);
        studentService.registStudent(studentDTO);
        return new ResponseEntity<>("注册成功", HttpStatusCode.valueOf(200));
    }

}
